<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工程合同管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../resources/css/style.css" media="all">
    <style>
        /*.layui-form-label{width: 100px;}*/
        /*.layui-form-pane .layui-form-label{width: 30%;}*/
        /*.layui-form-pane .layui-form-label{width: 32%;}*/
        /*#form_7grid .formTop .layui-inline .layui-input-inline{width:67%;}*/
        /*@media screen and (max-width: 1280px){*/
            /*.formTop .layui-inline .layui-input-inline {*/
                /*width: 80%;*/
            /*}*/
        /*}*/
        .layui-input-inline{width: 80%;}
        .layui-form-item .layui-input-inline{width: 80%;}
        .layui-form-item{clear: inherit;}
        .layui-input-block{width: 80%;}
        .layui-form-item,.layui-inline{margin-bottom: 10px;}
        .layui-table-cell{mso-number-format:"\@"!important;}
    </style>

</head>
<body>
<a class="dayin" id="dlink" style="float: right; position: fixed; right: 50px; bottom: 50px; z-index: 999;"></a>

<form class="layui-form layui-form-pane" id="form_7grid" action="" lay-filter="hetong">
    <div class="formTop" style="font-size:12px;">
        <div class="layui-form-item layui-col-md3 layui-col-sm3 layui-col-xs6">
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required" placeholder="项目名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-col-md3 layui-col-sm3 layui-col-xs6">
            <div class="layui-input-inline">
                <input type="text" name="buildName" lay-verify="required" placeholder="请输入施工单位名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline layui-col-md3 layui-col-sm3 layui-col-xs6">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="test-limit3" placeholder="请选择创建开始日期">
            </div>
        </div>
        <div class="layui-inline layui-col-md3 layui-col-sm3 layui-col-xs6">

            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="test-limit4" placeholder="请选择创建结束日期">

            </div>
        </div>
        <div class="layui-inline layui-col-md3 layui-col-sm3 layui-col-xs6" style="margin-bottom: 0;">
            <div class="layui-input-block" style="margin-left: 0;">
                <select name="state" lay-filter="aihao">
                    <option value="" selected="">请选择审核状态</option>
                    <option value="0">审核通过</option>
                    <option value="-1">等待审核</option>
                    <option value="1">不通过</option>
                </select>
            </div>
        </div>
        <div class="layui-col-md3 layui-col-sm3 layui-col-xs6">
            <button class="layui-btn tijiao" type="button" onclick="query()">查询</button>
            <button class="layui-btn layui-btn-normal quanxian" type="button" style="background-color: #ff8f3b;color: #FFF;margin: 0px; padding: 0;" QX="api/contract/insertContract.do" onclick="tiaozhuans()"><a style="color: #FFF; width: 100%;height: 100%;display: inline-block;background-color: #ff8f3b;width: 65px;border-radius: 5px;">添加</a></button>
            <button class="layui-btn layui-btn-normal quanxian" type="button" style="background-color: #ff8f3b;color: #FFF;margin: 0px; padding: 0;" QX="api/contract/insertContract.do" onclick="jumpOther()"><a style="color: #FFF; width: 100%;height: 100%;display: inline-block;background-color: #ff8f3b;width: 65px;border-radius: 5px;">其他合同</a></button>
            <button class="layui-btn quanxian" type="button" onclick="importConcract()" QX="impSysData.do" >导入合同</button>
        </div>

    </div>

    <table id="demo" lay-filter="test"></table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-sm bianji quanxian" lay-event="edit" QX="api/contract/updateContcract.do">编辑</a>
        <a class="layui-btn layui-btn-sm quanxian" lay-event="detail"  QX="api/contract/loadContractDetails.do">查看</a>
        <a class="layui-btn layui-btn-sm layui-btn-normal quanxian" lay-event="shenhe"  QX="api/contract/valiBuilProcess.do">审核</a>
        <a class="layui-btn layui-btn-danger layui-btn-sm  " lay-event="delete">删除</a>
    </script>
    <!--<script type="text/html" id="titleTpl">-->

        <!--<span>{{times(1510635999999)}}</span>-->

    <!--</script>-->
</form>
<div id="demo7"></div>


<script src="../../../resources/layui/layui.js" charset="utf-8"></script>
<script src="../../../resources/js/style.js"></script>
<script src="../../../resources/js/api.js"></script>

<!--<script src="../../../resources/js/jsjiazai.js"></script>-->
<script>

    function importConcract() {
        layer.open({
            title: '导入合同'
            ,btn:['下载模板']
            ,btnAlign: 'c'
            ,anim: 4
            ,shade: [0.8, '#393D49']
            ,scrollbar: false
            ,content: '<span style="color:red;" >首先下载模板进行填写规范数据，如果导入成功数据有问题请联系管理员删除！<span>' +
            '<br><div class="layui-upload-drag" id="test10"><i class="layui-icon"></i>' +
            '<p>点击上传，或将文件拖拽到此处</p></div>'
            ,yes: function(index, layero){
                //按钮【按钮一】的回调
                window.open(urls + "/download/hetong.xls");
                return false;
            }
        });
        layui.use(['table','upload'], function(){
            var layer = layui.layer
                ,table=layui.table
                ,upload=layui.upload
                ,$ = layui.jquery;

            upload.render({
                elem: '#test10'
                ,url: urls + '/impSysData.do'
                ,accept: 'file' //普通文件
                ,exts: 'xls|xlsx'
                ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                    layer.load(); //上传loading
                }
                ,done: function(res, index, upload){
                    layer.msg(res.msg);
                    layer.closeAll('loading'); //关闭loading
                }
                ,error: function(index, upload){
                    layer.msg("上传服务器出错！");
                    layer.closeAll('loading'); //关闭loading
                }
            });

        })


    }
        //走不到点击这一步对吧？ 能 咱这个不是个弹出层吗  我调用能弹出来，按钮事件无效


    function query() {
        layui.use(['form', 'layedit', 'laydate','table','element'], function() {
            var form = layui.form
                , table = layui.table;
            var pronName=$("[name='username']").val();
            var begintime=$('#test-limit3').val();
            var endtime=$('#test-limit4').val();
            var buildName=$('[name="buildName"]').val();
            var stast=$('[name="state"]').val();

            if(!AntiSqlValid(pronName)){
                if(lbq('api/contract/loadConcract.do')) {
                    API.contractAdmin({
                        'type': 'a',
                        'proName': pronName,
                        'begintime': begintime,
                        'endtime': endtime,
                        'buildName': buildName,
                        'state': stast,
                        'p': getCookie('yanzheng')
                    })
                }
            }else {
                layer.msg('请勿输入特殊符号');
            };
        })

    }

    function tiaozhuans() {
        location.href='./addTo.html';
    }
    function jumpOther(){
        location.href = './addToOther.html';
    }

    layui.use(['table','upload'], function(){
        var layer = layui.layer
            ,table=layui.table
            ,upload=layui.upload
            ,$ = layui.jquery;



        jiazais();



        $('.close').click(function () {     //遮罩层隐藏
            $('.mask').hide();
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
		var xiala=new Object;
        //执行渲染
        if(lbq('api/contract/loadConcract.do')){
            API.contractAdmin({'type':'a','p':getCookie('yanzheng')},function(){
                ////console.log(arguments, '坏笑');		//arguments对象是比较特别的一个对象，实际上是当前函数的一个内置属性。arguments非常类似Array，但实际上又不是一个Array实例
                xiala=arguments[0];
                sessionStorage.setItem('xialaCont',JSON.stringify(xiala));
                ////console.log(arguments[0]);
    //      	$("[name='comptype']").html('')
    //			for(var i=0;i<xiala.compDropDown.length;i++){
    //				$("[name='comptype']").append('<option value="'+xiala.compDropDown[i].p_value+'">'+xiala.compDropDown[i].p_name+'</option>')
    //			}
    //      	form.render();

            });
        }

             //前后若干天可选，这里设置不能选过去的日期      最远可选1000天之后
        panduanshijiantow('#test-limit3','#test-limit4',1000,1000,'.tijiao');     //查询 开始结束时间判断


        var pans=true;



        //监听工具条
        table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'detail'){ //查看
                //do somehing
                ////console.log(obj)
                sessionStorage.id=obj.data.cc_UUID;         //缓存id 至详情页调用
                window.location.href='./details.html';
            } else if(layEvent === 'shenhe'){ //删除
                ////console.log(pans);

                if(pans){
                      pans=false;
                      ajaxs('/api/contract/valiBuilProcess.do','post',{'cc_uuid':obj.data.cc_UUID,'p':getCookie('yanzheng')},function(data) {
                          ////console.log(data);
                              layer.msg(data.msg);
                              if(data.code==0){
                                  setTimeout(function () {
                                      location.reload();
                                  },1500)
                              }
                      })


                }

            } else if(layEvent === 'edit'){ //编辑
                //普通合同和三方合同的渲染方式不同
                sessionStorage.id=obj.data.cc_UUID;         //缓存id 至修改页调用
                if(obj.data.c_type && obj.data.c_type === 1 ){
                    window.location.href='./modify1.html';
                } else{
                    window.location.href='./modify.html';
                }
            } else if (layEvent === 'delete'){
                //询问框
                layer.confirm('您是否要删除？', {
                    btn: ['删除','取消'] //按钮
                }, function(){
                    ajaxs('/api/contract/delConcract.do',
                        'post',
                        {'cc_uuid':obj.data.cc_UUID,
                            'ccCode': obj.data.cc_code,
                            'p':getCookie('yanzheng')
                        },
                        function(data) {
                        layer.msg(data.msg);
                        if(data.code==0){
                            setTimeout(function () {
                                location.reload();
                            },1500)
                        }
                    })
                }, function(){
                });
            }
        });

        dayintishi('.dayin');


    })

</script>
</body>
</html>